function getUpToken(fileName) {
    var token;
    //获取七牛token
    $.ajax({
        type: "POST",
        url: "getUpToken.do?fileName="+fileName,
        async: false,
        success: function (result) {
            if(result&&result.code==0){
                token=result.data;
            }
        }
    });
    return token;
}
QiniuUrl='http://static.vc-group.cn/';

function putb64(pic,token){
    if(!pic){
        top.myLayer.confirm('上传内容不能为空');
        return;
    }
    if(!token){
        top.myLayer.confirm('上传token不能为空');
        return;
    }
    if(pic.indexOf("base64,")!=-1){
        pic=pic.substring(pic.indexOf(",")+1);
    }
    // var url = "http://upload-z2.qiniu.com/putb64/-1";
    var url = "http://up-z2.qiniup.com/putb64/-1";
    var xhr = new XMLHttpRequest();
    xhr.onreadystatechange=function(){
        if (xhr.readyState==4){
            var result=JSON.parse(xhr.responseText);
            if(result&&result.key){
                $('#myDiv').val(result.key);
                top.myLayer.confirm('上传成功 '+xhr.responseText);
            }else {
                top.myLayer.confirm('上传失败! '+xhr.responseText);
            }
        }
    }

    xhr.open("POST", url, true);
    xhr.setRequestHeader("Content-Type", "application/octet-stream");
    xhr.setRequestHeader("Authorization", "UpToken "+token);
    try{
        xhr.send(pic);
    }catch (e) {
        console.log(e);
    }
}